home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
-
- BigArray
-
- This class implements arrays that can be more than 32K in size and store
- any kind of element.
-
- By: Eric Yiskis
-
- ******************************************************************************/
-
- #define _H_CBigArray
-
- #include <Global.h> /* handy declarations */
- #include <CObject.h> /* Interface for its superclass */
- #include <CDataFile.h>
- #include <CApplication.h>
-
- extern CApplication *gApplication;
-
- /*-------------------------------------------------------------------------------*/
-
- typedef struct {
- long nElements; /* number of elements allocated */
- int nElementSize; /* length in bytes of each element */
- } AMFData; /* Array Mapping Function data */
-
- /*-------------------------------------------------------------------------------*/
-
- struct CBigArray : CObject {
-
- /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
- /* Instance Variables */
-
- Handle hData;
- AMFData amf;
-
- /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
- /* Instance Methods */
-
- /*-- Creation/Termination --*/
- void IBigArray(void);
- /* pre - Object has been allocated but not initialized */
- /* post- Object has been initialized */
-
- Boolean CreateData(long nElements,int nElementSizeIn,Handle hDataIn);
- /* pre - Object has been initialized but not created by CreateData or */
- /* LoadData. */
- /* hDataIn contains NULL or contains data that matches */
- /* nMaxElements, and nElementSizeIn dimension parameters. */
- /* post- if hDataIn == NULL, returns TRUE if array matching the */
- /* dimensions could be allocated, otherwise returns FALSE. */
- /* if hDataIn != NULL, hDataIn is assumed to be an array that */
- /* matches the dimension parameters. */
- /* note- If loading an object from a file, use the LoadData method to */
- /* instead. */
-
- Boolean ResizeArray(long nNewNumberOfElements);
- /* pre Object has been loaded with CreateData or LoadData. */
- /* post Elements are added or truncated util there are */
- /* nNewNumberOfElements in the array. Returns FALSE if the */
- /* resize was unsuccessful. */
-
- void Dispose(void); /* OVERRIDE */
-
-
- /*-- Element Manipulation --*/
- void SetValue(long nIndex,char *pSource);
- /* pre - Object has been created by CreateData or LoadData methods */
- /* post- data at pSource is copied into location nIndex */
-
- void GetValue(long nIndex,char *pDestination);
- /* pre - Object has been created by CreateData or LoadData methods */
- /* post- data at pSource is copied into location nIndex */
-
- /*-- I/O --*/
- OSErr LoadData(CDataFile *datafile);
- /* pre - Object has been initialized but not created by CreateData or */
- /* LoadData. */
- /* datafile is open. */
- /* post- returns the error condition of the attempt to read. */
- /* if the error condition == NoErr then the object is */
- /* initialized with the data from datafile. */
-
- OSErr SaveData(CDataFile *datafile);
- /* pre - Object has been created by CreateData or LoadData methods */
- /* datafile is open. */
- /* post- returns the error condition of the attempt to write. */
- /* if the error condition == NoErr then the data has been written */
-
-
- /*-- Misc --*/
- void GetDimensions(long *nElements, int *nElementSizeOut);
- /* pre - Object has been created by CreateData or LoadData methods */
- /* post- parameters contain dimensions of the array. */
-
- Handle GetData(void);
- /* pre - Object has been created by CreateData or LoadData methods */
- /* post- Returns a handle to the data. */
-
- /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
- /* private */
-
- long Offset(long nIndex);
- /* returns offset (bytes) of element from the beginning of the data handle */
- };
-